package com.todo.message.application.core.receipt.stater.impl;

import com.todo.common.common.constants.CommonConstant;
import com.todo.message.application.core.receipt.stater.ReceiptMessageStater;
import com.todo.message.infrastructure.enums.ChannelType;
import com.todo.message.application.handler.operation.impl.DingDingWorkNoticeHandler;
import com.todo.message.infrastructure.mapper.ChannelAccountMapper;
import com.todo.message.infrastructure.po.ChannelAccount;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 拉取 钉钉工作消息的回执 内容 【未完成】
 *
 * @author 3y
 */
@Component
@Slf4j
public class DingDingWorkReceiptStaterImpl implements ReceiptMessageStater {

    @Autowired
    private DingDingWorkNoticeHandler workNoticeHandler;

    @Autowired
    private ChannelAccountMapper channelAccountDao;

    @Override
    public void start() {
        List<ChannelAccount> accountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.DING_DING_WORK_NOTICE.getCode());
        for (ChannelAccount channelAccount : accountList) {
            workNoticeHandler.pull(channelAccount.getId());
        }
    }
}
